package Demo2;

import java.math.BigDecimal;

public class MyBigDecimal {
    public static void main(String[] args) {
        //首先创建BigDecimal对象
        BigDecimal b1 = new BigDecimal("1");
        BigDecimal b2 = new BigDecimal("0.3");
        //加法
        System.out.println(b1.add(b2));
        //减法
        System.out.println(b1.subtract(b2));
        //乘法
        System.out.println(b1.multiply(b2));

        //System.out.println(b1.divide(b2));
        BigDecimal divide = b1.divide(b2,1,BigDecimal.ROUND_HALF_UP);
        System.out.println(divide);

    }
}
